home *** CD-ROM | disk | FTP | other *** search
/ Hardcore Visual Basic 5.0 (2nd Edition) / Hardcore Visual Basic 5.0 - Second Edition (1997)(Microsoft Press).iso / Code / Goodies / CallBack / CBSCROLL.FRM < prev    next >
Text File  |  1997-06-09  |  6KB  |  186 lines

  1. VERSION 5.00
  2. Begin VB.Form CallbackDemo 
  3.    Caption         =   "Callback Demonstrator"
  4.    ClientHeight    =   4824
  5.    ClientLeft      =   1200
  6.    ClientTop       =   1536
  7.    ClientWidth     =   9336
  8.    LinkTopic       =   "Form2"
  9.    PaletteMode     =   1  'UseZOrder
  10.    ScaleHeight     =   4824
  11.    ScaleWidth      =   9336
  12.    Begin VB.TextBox txtDllName 
  13.       Appearance      =   0  'Flat
  14.       Height          =   285
  15.       Left            =   5640
  16.       TabIndex        =   10
  17.       Text            =   "comdlg32.dll"
  18.       Top             =   240
  19.       Width           =   2415
  20.    End
  21.    Begin VB.CommandButton btnEnumIcons 
  22.       Caption         =   "Enumerate Strings In Dll"
  23.       Height          =   375
  24.       Left            =   5640
  25.       TabIndex        =   9
  26.       Top             =   600
  27.       Width           =   2295
  28.    End
  29.    Begin VB.ListBox lstResources 
  30.       Appearance      =   0  'Flat
  31.       Height          =   1560
  32.       Left            =   5640
  33.       TabIndex        =   8
  34.       Top             =   1200
  35.       Width           =   2415
  36.    End
  37.    Begin VB.ListBox lstFonts 
  38.       Appearance      =   0  'Flat
  39.       Height          =   1560
  40.       Left            =   3000
  41.       TabIndex        =   7
  42.       Top             =   1200
  43.       Width           =   2325
  44.    End
  45.    Begin VB.CommandButton btnEnumFonts 
  46.       Appearance      =   0  'Flat
  47.       BackColor       =   &H80000005&
  48.       Caption         =   "Enumerate Fonts"
  49.       Height          =   375
  50.       Left            =   3000
  51.       TabIndex        =   6
  52.       Top             =   600
  53.       Width           =   2085
  54.    End
  55.    Begin VB.CommandButton btnGetTaskWindows 
  56.       Appearance      =   0  'Flat
  57.       BackColor       =   &H80000005&
  58.       Caption         =   "Get Task Windows"
  59.       Height          =   435
  60.       Left            =   180
  61.       TabIndex        =   5
  62.       Top             =   1740
  63.       Width           =   2265
  64.    End
  65.    Begin VB.ListBox lstWindows 
  66.       Appearance      =   0  'Flat
  67.       Height          =   1944
  68.       Left            =   210
  69.       TabIndex        =   3
  70.       Top             =   2250
  71.       Width           =   2265
  72.    End
  73.    Begin VB.CommandButton btnEnumVisibleWindows 
  74.       Appearance      =   0  'Flat
  75.       BackColor       =   &H80000005&
  76.       Caption         =   "Get All Visible Windows"
  77.       Height          =   435
  78.       Left            =   150
  79.       TabIndex        =   2
  80.       Top             =   1230
  81.       Width           =   2265
  82.    End
  83.    Begin VB.CommandButton btnScrollBarsOff 
  84.       Appearance      =   0  'Flat
  85.       BackColor       =   &H80000005&
  86.       Caption         =   "ScrollBars Off"
  87.       Height          =   465
  88.       Left            =   120
  89.       TabIndex        =   1
  90.       Top             =   690
  91.       Width           =   2385
  92.    End
  93.    Begin VB.CommandButton btnScrollBarsOn 
  94.       Appearance      =   0  'Flat
  95.       BackColor       =   &H80000005&
  96.       Caption         =   "ScrollBars On"
  97.       Height          =   465
  98.       Left            =   120
  99.       TabIndex        =   0
  100.       Top             =   150
  101.       Width           =   2415
  102.    End
  103.    Begin VB.Label lblHWND 
  104.       Caption         =   "HWND = "
  105.       Height          =   375
  106.       Left            =   240
  107.       TabIndex        =   4
  108.       Top             =   4320
  109.       UseMnemonic     =   0   'False
  110.       Width           =   2265
  111.    End
  112. End
  113. Attribute VB_Name = "CallbackDemo"
  114. Attribute VB_GlobalNameSpace = False
  115. Attribute VB_Creatable = False
  116. Attribute VB_PredeclaredId = True
  117. Attribute VB_Exposed = False
  118. Option Explicit
  119.  
  120. Private ScrollCB As New ScrollBarDriver
  121.  
  122. Private Sub btnEnumFonts_Click()
  123. Dim Enumerator As New FontEnumerator
  124.     lstFonts.Clear
  125.     EnumFontFamilies hdc, vbNullString, Enumerator.ProcAddress, lstFonts
  126. End Sub
  127.  
  128. Private Sub btnEnumIcons_Click()
  129. Dim Enumerator As New ResourceEnumerator
  130.     Enumerator.FillListWithStringIds txtDllName, lstResources
  131. End Sub
  132.  
  133. Private Sub btnEnumVisibleWindows_Click()
  134. Dim Enumerator As New WindowEnumerator
  135.     lstWindows.Clear
  136.     EnumWindows Enumerator.ProcAddress, lstWindows
  137. End Sub
  138.  
  139. Private Sub btnGetTaskWindows_Click()
  140. Dim Enumerator As New WindowEnumerator
  141.     lstWindows.Clear
  142.     Enumerator.Recurse = False
  143.     EnumThreadWindows GetCurrentThreadId, Enumerator.ProcAddress, lstWindows
  144. End Sub
  145.  
  146. Private Sub btnScrollBarsOff_Click()
  147. Dim lCurrent As Long
  148.     lCurrent = GetWindowLong(hWnd, GWL_STYLE)
  149.     lCurrent = Not (lCurrent Imp (WS_HSCROLL Or WS_VSCROLL))
  150.     SetWindowLong hWnd, GWL_STYLE, lCurrent
  151.     SetWindowPos hWnd, 0, 0, 0, 0, 0, SWP_DRAWFRAME Or SWP_NOMOVE Or SWP_NOSIZE Or SWP_NOZORDER Or SWP_NOACTIVATE
  152.     ScrollCB.UnsubClass
  153. End Sub
  154.  
  155. Private Sub btnScrollBarsOn_Click()
  156. Dim lCurrent As Long
  157. Dim sbMax As Long, sbMin As Long
  158.     lCurrent = GetWindowLong(hWnd, GWL_STYLE)
  159.     lCurrent = lCurrent Or WS_HSCROLL Or WS_VSCROLL
  160.     SetWindowLong hWnd, GWL_STYLE, lCurrent
  161.     SetWindowPos hWnd, 0, 0, 0, 0, 0, SWP_DRAWFRAME Or SWP_NOMOVE Or SWP_NOSIZE Or SWP_NOZORDER Or SWP_NOACTIVATE
  162.     ScrollCB.SubClass hWnd
  163. End Sub
  164.  
  165. Private Sub Form_Load()
  166.     'To SubClass in Win16, be sure the form is already
  167.     'visible before turning on subclassing.  Otherwise, if any
  168.     'controls have Appearance set to 3d, there are nasty interactions
  169.     'with Ctl3dv2.dll, which is also subclassing.
  170.     btnScrollBarsOn_Click
  171.     With ScrollCB
  172.         .VScroll.Max = 100
  173.         .HScroll.Max = 100
  174.     End With
  175. End Sub
  176.  
  177. Private Sub Form_Unload(Cancel As Integer)
  178.     btnScrollBarsOff_Click
  179. End Sub
  180.  
  181. Private Sub lstWindows_Click()
  182.     With lstWindows
  183.         lblHWND = "HWND = &H" & Hex$(.ItemData(.ListIndex))
  184.     End With
  185. End Sub
  186.